home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.3)
-
- import string
- import cStringIO
-
- class CommsException(Exception):
-
- def __init__(self, device, message):
- Exception.__init__(self, '%s: %s' % (device, message))
- self.device = device
- self.message = message
-
-
-
- class CommsNeedConfiguring(CommsException):
-
- def __init__(self, device, message):
- CommsException.__init__(self, device, message)
- self.device = device
- self.message = message
-
-
-
- class CommsDeviceNeedsAttention(CommsException):
-
- def __init__(self, device, message):
- CommsException.__init__(self, device, message)
- self.device = device
- self.message = message
-
-
-
- class CommsTimeout(CommsException):
-
- def __init__(self, device, message):
- CommsException.__init__(self, device, message)
- self.device = device
- self.message = message
-
-
-
- class CommsOpenFailure(CommsException):
-
- def __init__(self, device, message):
- CommsException.__init__(self, device, message)
- self.device = device
- self.message = message
-
-
-
- class AutoPortsFailure(CommsException):
-
- def __init__(self, portstried):
- self.device = 'auto'
- self.message = 'Failed to auto-detect the port to use. '
- CommsException.__init__(self, self.device, self.message)
-
-
-
- def datatohexstring(data):
- res = cStringIO.StringIO()
- lchar = ''
- lhex = '00000000 '
- for count in range(0, len(data)):
- b = ord(data[count])
- lhex = lhex + '%02x ' % (b,)
- if b >= 32 and string.printable.find(chr(b)) >= 0:
- lchar = lchar + chr(b)
- else:
- lchar = lchar + '.'
- if (count + 1) % 16 == 0:
- res.write(lhex + ' ' + lchar + '\n')
- lhex = '%08x ' % (count + 1,)
- lchar = ''
- continue
-
- if len(data):
- while (count + 1) % 16 != 0:
- count = count + 1
- lhex = lhex + ' '
- res.write(lhex + ' ' + lchar + '\n')
-
- return res.getvalue()
-
-
- def prettyprintdict(dictionary, indent = 0):
- res = ''
- istr = ' '
- res += '%s{\n' % (istr * indent,)
- indent += 1
- keys = dictionary.keys()
- keys.sort()
- for k in keys:
- v = dictionary[k]
- if isinstance(v, dict):
- res += '%s%s:\n%s,\n' % (istr * indent, `k`, prettyprintdict(v, indent + 1))
- continue
- res += '%s%s: %s,\n' % (istr * indent, `k`, `v`)
-
- indent -= 1
- res += '%s}\n' % (istr * indent,)
- return res
-
-
- class exceptionwrap:
-
- def __init__(self, callable):
- self.callable = callable
-
-
- def __call__(self, *args, **kwargs):
-
- try:
- print 'in exception wrapped call'
- res = self.callable(*args, **kwargs)
- print `self.callable`, 'returned', datatohexstring(res)
- return res
- except:
- import traceback
- traceback.print_stack()
- traceback.print_exc()
- raise
-
-
-
-
- def readversionedindexfile(filename, dict, versionhandlerfunc, currentversion):
- execfile(filename, dict, dict)
- if not dict.has_key('FILEVERSION'):
- version = 0
- else:
- version = dict['FILEVERSION']
- del dict['FILEVERSION']
- if version < currentversion:
- versionhandlerfunc(dict, version)
-
-
-
- def writeversionindexfile(filename, dict, currentversion):
- f = open(filename, 'w')
- for key in dict:
- f.write("result['%s']=%s\n" % (key, prettyprintdict(dict[key])))
-
- f.write('FILEVERSION=%d\n' % (currentversion,))
- f.close()
-
-